<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>项目设置</title>
	<link rel="icon" href="../../img/icon.png" type="image/x-icon"/>
	<link rel="stylesheet" type="text/css" href="../../css/mui.css"/>
	<link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
	<link rel="stylesheet" type="text/css" href="../../css/app.css"/>
</head>
<body>
<!-- 顶部菜单 -->
<ul id="top">
	<!-- <li class="addBug back" onclick="mui.back();">返回</li> -->
	<li class="addBug back" onclick="jumpToMy()">返回</li>
	<li class="addBug">项目列表</li>
	<li class="addBug pub" onclick="jumpToMyProAdd()">新增</li>
</ul>
<!-- 主体 -->
<div style="height: 50px;"></div>
<ul class="mui-table-view" id="datalist">
    <!-- <li class="mui-table-view-cell">
        <a class="mui-navigate-right">项目名称</a>
    </li> -->
</ul>
<div style="height: 50px;"></div>
<!-- 底部菜单 -->
<ul id="foot">
	<li class="noclick" onclick="jumpToIndex()">BUG</li>
	<li class="noclick" onclick="jumpToHistory()">历史</li>
	<li class="noclick" onclick="jumpToMore()">更多</li>
	<li>我的</li>
</ul>
</body>
</html>


<script type="text/javascript" src="../../js/mui.min.js"></script>
<script type="text/javascript" src="../../js/app.js"></script>
<script type="text/javascript">
	var domain = getDomain();
	(function($, owner) {
		getProList();
	}(mui, window.app = {}));
	//项目获取
	function getProList(){
		var token = getAdminToken();
		//数据加载
		mui.toast('数据加载中！',{ 
			duration:'long', type:'div',
		});
		mui.ajax(domain+'/app/project/index',{
			data:{
				token:token
			},
			dataType:'json',//服务器返回json格式数据
			type:'post',//HTTP请求类型
			timeout:10000,//超时时间设置为10秒；
			// headers:{'Content-Type':'application/json'},
			headers:{'Content-Type':'application/x-www-form-urlencoded'}, 
			async: true,  //async: true || false, // 异步 || 同步
			crossDomain: true,  //强制跨域
			success:function(res){
				console.log('OK',res); 
				// return
				var list = '';
				if (res.code!=0) {
					list += '<li class="mui-table-view-cell">';
					list += '<a class="mui-navigate-right">';
					list += '没有项目数据';
					list += '</a>';
					list += '</li>';
					mui("#datalist")[0].innerHTML = list;
					mui.toast(res.msg+'！',{ 
						duration:'long', type:'div',
					});
					return
				}
				var datalist = res.data;
				for (var i=0;i<datalist.length;i++) {
					list += '<li class="mui-table-view-cell" ';
					list += 'onclick="setPro('+datalist[i].proId+')">';
					list += '<a class="mui-navigate-right">';
					list += datalist[i].proName;
					list += '</a>';
					list += '<input type="hidden" id="proName'+datalist[i].proId+'" value="'+datalist[i].proName+'"/>';
					list += '<input type="hidden" id="proDetail'+datalist[i].proId+'" value="'+datalist[i].proDetail+'"/>';
					list += '</li>';
				}
				mui("#datalist")[0].innerHTML = list;
			},
			error:function(xhr,type,errorThrown){
				// console.log('网络错误');
				mui.toast(xhr+type+'网络错误！',{
					duration:'long', type:'div',
				});
			}
		});
	}
	//设置当前项目
	function setPro(proId){
		var proName = mui("#proName"+proId)[0].value;
		var proDetail = mui("#proDetail"+proId)[0].value;
		console.log(proId,proName);
		var proInfo = {
			'proId':proId,
			'proName':proName,
			'proDetail':proDetail
		};
		cacheSet(proInfoKey,proInfo);
		mui.toast('设置成功！',{ 
			duration:'long', type:'div',
		});
	}
</script>